package com.ymatou.iapi.livemanage.testcase;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.livemanage.service.ModifyActivityCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AssertService;
import com.ymttest.business.service.LiveCallService;
import com.ymttest.business.service.NewJavaMongoCheckService;
import com.ymttest.business.service.SellerProductCallService;
import com.ymttest.database.mongo.LiveBasicInfoWapper;
import com.ymttest.database.mongo.LiveModelWapper;
import com.ymttest.database.mongo.YmtMongoDriverFactroy;
import com.ymttest.database.sqlwapper.YmtLiveWapper;
import com.ymttest.database.sqlwapper.YmtProductsIWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.MapUtil;
import com.ymttest.utils.YMTDateUtil;

public class Ts_ModifyActivity {
	private static ModifyActivityCall modifyActivityCall;
	private static Integer sellerId = Integer.valueOf(EnvSetup.getData("productsellerid"));
	private static String sellerName = EnvSetup.getData("productsellername");
	private static Integer sellerId1 = Integer.valueOf(EnvSetup.getData("productsellerid4"));
	private static String sellerName1 = EnvSetup.getData("productsellername4");

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("修改直播");
	}

	@Before
	public void caseUp() {
		modifyActivityCall=new ModifyActivityCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(modifyActivityCall.getOpurl());
	}
	
	/**
	 * sql映射关系
	 * @return
	 * @throws Exception
	 */
	public Map<String,String> sqlMap() throws Exception {
	    try {	    	
	    	Map<String,String> sqlMap = new HashMap<String,String>();
		    	sqlMap.put("ActivityRequest->UserId", "iSellerId");
		    	sqlMap.put("ActivityRequest->ActivityName", "sName");
		    	sqlMap.put("ActivityRequest->PicUrl", "sPicUrl");
		    	sqlMap.put("ActivityRequest->ActivityContent", "sContent");
		    	sqlMap.put("ActivityRequest->Title", "sTitle");
			return sqlMap;
	    }catch (Exception e) {  
	        e.printStackTrace();	        
	    }  
	    return null;
	}
	
	public void getReturnCode(JSONObject dataStr) throws Exception {
	    try {	    	
			//返回报文断言		
			String code =  dataStr.getString("Code");
			Logger.verifyIsContains(200, code, "\"Code\":200");
			String bCode =  dataStr.getString("BCode");
			Logger.verifyIsContains(0, bCode, "\"BCode\":0");
			String msg =  dataStr.getString("Msg");
			Logger.verifyIsContains("操作成功", msg, "\"Msg\":操作成功");	
	    	
	    }catch (Exception e) {  
	        e.printStackTrace();
	    }  
	}
	
	
	/**
	 * oldMongo映射关系(主动缓存老库)
	 * @return
	 * @throws Exception
	 */
	public Map<String,String> oldMongoMap() throws Exception {
	    try {	    	
	    	Map<String,String> oldMongoMap = new HashMap<String,String>();
		    	oldMongoMap.put("ActivityRequest->UserId", "SellerId");
		    	oldMongoMap.put("ActivityRequest->ActivityName", "ActivityName");
		    	oldMongoMap.put("ActivityRequest->PicUrl", "ActivityPicture");
		    	oldMongoMap.put("ActivityRequest->ActivityContent", "ActivityContent");
		    	oldMongoMap.put("ActivityRequest->Title", "Title");
			return oldMongoMap;
	    }catch (Exception e) {  
	        e.printStackTrace();	        
	    }  
	    return null;
	}
	
	
	/**
	 * newMongo映射关系(主动缓存老库)
	 * @return
	 * @throws Exception
	 */
	public Map<String,String> newMongoMap() throws Exception {
	    try {	    	
	    	Map<String,String> newMongoMap = new HashMap<String,String>();
		    	newMongoMap.put("ActivityRequest->UserId", "SellerId");
		    	newMongoMap.put("ActivityRequest->ActivityName", "ActivityName");
		    	newMongoMap.put("ActivityRequest->PicUrl", "ActivityPicture");
		    	newMongoMap.put("ActivityRequest->ActivityContent", "ActivityContent");
		    	newMongoMap.put("ActivityRequest->Title", "Title");
			return newMongoMap;
	    }catch (Exception e) {  
	        e.printStackTrace();	        
	    }  
	    return null;
	}
	

	@After
	public void caseDown() {
		Logger.end();
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ModifyActivity_001() {
		Logger.start(true,"修改直播（正在进行中的直播）");
		try{
			//TODO 补全case代码	
			Integer activityId = LiveCallService.createLiveInProgress(sellerName,sellerId).getJSONObject("Data").getInt("ActivityId");
			
			//add product 
			 JSONObject productBean = SellerProductCallService.addNewProductNotOnSale(sellerId,sellerName,null);
			 String productId =	productBean.getJSONObject("Data").getString("ProductID");
			 SellerProductCallService.addProductInLive(sellerId,activityId,productId);
				
			 //直播地名称
			 String ActivityName = "自动化测试  - 直播地名称";
			 
			 //直播图片
			 String PicUrl = "http://pc1.img.ymatou.com/G01/M00/0A/C9/rBBlD1b0p-2AF1waAAAGdC5-fgw197_c.jpg";
			 
			 //直播介绍
			 String ActivityContent = "自动化测试 - 直播介绍";
			 
			 //直播名称
			 String Title = "自动化测试 - 直播名称";
			 //开始时间结束时间
			 Calendar c = Calendar.getInstance();
			 c.add(Calendar.HOUR, -8);
			 Date startTime = c.getTime();
			 c.add(Calendar.HOUR, 16);
			 Date endTime = c.getTime();
			 
			 
			//修改报文参数
			 Map<String, Object> updateMap = new HashMap<String, Object>();
			 updateMap.put("ActivityRequest->ActivityId", activityId);
			 updateMap.put("ActivityRequest->UserId", sellerId);
			 updateMap.put("ActivityRequest->ActivityName", ActivityName);
			 updateMap.put("ActivityRequest->PicUrl", PicUrl);
			 updateMap.put("ActivityRequest->ActivityContent", ActivityContent);
			 updateMap.put("ActivityRequest->StartTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(startTime));
			 updateMap.put("ActivityRequest->EndTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(endTime));
			 updateMap.put("ActivityRequest->Title", Title);
			 
			//call 
			JSONObject result = modifyActivityCall.callAndGetReturnData(updateMap);
			JSONObject jsonBeanRequest = result.getJSONObject("JsonBeanRequest");
			Logger.debug(result);
			
			//断言
			checkModifyActivity(activityId, jsonBeanRequest, startTime, endTime);									
			
			
			//新品时间检查
			SellerProductCallService.checkListingTime(productId, YMTDateUtil.getDate());
			
			if (YmtMongoDriverFactroy.isNewJavaMgoCheck()) {
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(activityId,productId);
			}
			
		}catch(Exception e){
			Logger.fail(e);
		}
				
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ModifyActivity_002() {
		Logger.start(true,"修改直播（即将开始的直播）");
		try{
			//TODO 补全case代码	
			Integer activityId = LiveCallService.createLiveBeginInFuture(sellerName,sellerId).getJSONObject("Data").getInt("ActivityId");
					
			//add product 
			 JSONObject productBean = SellerProductCallService.addNewProductNotOnSale(sellerId,sellerName,null);
			 String productId =	productBean.getJSONObject("Data").getString("ProductID");
			 SellerProductCallService.addProductInLive(sellerId,activityId,productId);
			 
			 
			 //直播地名称
			 String ActivityName = "自动化测试  - 直播地名称";
			 
			 //直播图片
			 String PicUrl = "http://pc1.img.ymatou.com/G01/M00/0A/C9/rBBlD1b0p-2AF1waAAAGdC5-fgw197_c.jpg";
			 
			 //直播介绍
			 String ActivityContent = "自动化测试 - 直播介绍";
			 
			 //直播名称
			 String Title = "自动化测试 - 直播名称";
			 //开始时间结束时间
			 Calendar c = Calendar.getInstance();
			 c.add(Calendar.HOUR, 8);
			 Date startTime = c.getTime();
			 c.add(Calendar.HOUR, 16);
			 Date endTime = c.getTime();
			 
			 //修改报文参数
			 Map<String, Object> updateMap = new HashMap<String, Object>();
			 updateMap.put("ActivityRequest->ActivityId", activityId);
			 updateMap.put("ActivityRequest->UserId", sellerId);
			 updateMap.put("ActivityRequest->ActivityName", ActivityName);
			 updateMap.put("ActivityRequest->PicUrl", PicUrl);
			 updateMap.put("ActivityRequest->ActivityContent", ActivityContent);
			 updateMap.put("ActivityRequest->StartTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(startTime));
			 updateMap.put("ActivityRequest->EndTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(endTime));
			 updateMap.put("ActivityRequest->Title", Title);

			//call 
			JSONObject result = modifyActivityCall.callAndGetReturnData(updateMap);
			JSONObject jsonBeanRequest = result.getJSONObject("JsonBeanRequest");
			
			//断言
			checkModifyActivity(activityId, jsonBeanRequest, startTime, endTime);	
			
			
			//新品时间检查
			SellerProductCallService.checkListingTime(productId, null);
			
			if (YmtMongoDriverFactroy.isNewJavaMgoCheck()) {
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(activityId,productId);
			}
			
		}catch(Exception e){
			Logger.fail(e);
		}
		
		
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ModifyActivity_003() {
		Logger.start(true,"修改直播（APP未定位的直播的直播）");
		try{
			//TODO 补全case代码	
			Integer activityId = LiveCallService.createLiveNotInEffect(sellerName,sellerId).getJSONObject("Data").getInt("ActivityId");
				
			//add product 
			 JSONObject productBean = SellerProductCallService.addNewProductNotOnSale(sellerId,sellerName,null);
			 String productId =	productBean.getJSONObject("Data").getString("ProductID");
			 SellerProductCallService.addProductInLive(sellerId,activityId,productId);
			 
			 
			 //直播地名称
			 String ActivityName = "自动化测试  - 直播地名称";
			 
			 //直播图片
			 String PicUrl = "http://pc1.img.ymatou.com/G01/M00/0A/C9/rBBlD1b0p-2AF1waAAAGdC5-fgw197_c.jpg";
			 
			 //直播介绍
			 String ActivityContent = "自动化测试 - 直播介绍";
			 
			 //直播名称
			 String Title = "自动化测试 - 直播名称";
			 //开始时间结束时间
			 Calendar c = Calendar.getInstance();
			 c.add(Calendar.HOUR, 8);
			 Date startTime = c.getTime();
			 c.add(Calendar.HOUR, 16);
			 Date endTime = c.getTime();
			 
			 //修改报文参数
			 Map<String, Object> updateMap = new HashMap<String, Object>();
			 updateMap.put("ActivityRequest->ActivityId", activityId);
			 updateMap.put("ActivityRequest->UserId", sellerId);
			 updateMap.put("ActivityRequest->ActivityName", ActivityName);
			 updateMap.put("ActivityRequest->PicUrl", PicUrl);
			 updateMap.put("ActivityRequest->ActivityContent", ActivityContent);
			 updateMap.put("ActivityRequest->StartTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(startTime));
			 updateMap.put("ActivityRequest->EndTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(endTime));
			 updateMap.put("ActivityRequest->Title", Title);

			//call 
			JSONObject result = modifyActivityCall.callAndGetReturnData(updateMap);
			JSONObject jsonBeanRequest = result.getJSONObject("JsonBeanRequest");
			
			//断言
			checkModifyActivity(activityId, jsonBeanRequest, startTime, endTime);	
			
			
			//新品时间检查
			SellerProductCallService.checkListingTime(productId, null);
			
			if (YmtMongoDriverFactroy.isNewJavaMgoCheck()) {
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(activityId,productId);
			}
			
		}catch(Exception e){
			Logger.fail(e);
		}
		
		
	}	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ModifyActivity_004() {
		Logger.start(true,"listingtime已过，编辑直播时间,listingtime不变");
		try{
			//创建一个直播
			Integer activityid = LiveCallService.createLiveBeginInFuture(sellerName1, sellerId1).getJSONObject("Data").getInt("ActivityId");
			//发布一个立即上架的商品
			String productID = SellerProductCallService.addNewProductOnSale(sellerId1, sellerName1, null).getJSONObject("Data").getString("ProductID");
			//商品加入直播
			SellerProductCallService.addProductInLive(sellerId1,activityid,productID);
			//组装请求并CALL接口
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, 2);
			Date startTime = c.getTime();
			c.add(Calendar.HOUR, 16);
			Date endTime = c.getTime();
			Map<String, Object> updateMap = new HashMap<String, Object>();
			updateMap.put("ActivityRequest->UserId", sellerId1);
			updateMap.put("ActivityRequest->ActivityId", activityid);
			updateMap.put("ActivityRequest->StartTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(startTime));
			updateMap.put("ActivityRequest->EndTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(endTime));
			JSONObject result = modifyActivityCall.callAndGetReturnData(updateMap);
			JSONObject jsonBeanRequest = result.getJSONObject("JsonBeanRequest");			
			//检查listingtime
			SellerProductCallService.checkSqlListingTime(productID, 2);
			SellerProductCallService.checkListingTime(productID, null);
			
			if (YmtMongoDriverFactroy.isNewJavaMgoCheck()) {
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(activityid,productID);
			}
			
		}catch(Exception e){
			Logger.fail(e);
		}
		
		
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ModifyActivity_005() {
		Logger.start(true,"listingtime未过，编辑直播时间，直播A<修改后的直播时间B<商品上架时间，listingtime为直播A开始时间");
		try{
			//创建多个直播
			List<Integer> list = LiveCallService.createLivesInFuture(sellerId1, sellerName1, 2, 1);
			//发布一个5天之后上架的商品
			String productID = SellerProductCallService.addNewProductOnTime(sellerId1, sellerName1, null).getJSONObject("Data").getString("ProductID");
			//商品加入直播
			SellerProductCallService.addProductInLive(sellerId1,list.get(0),productID);
			SellerProductCallService.addProductInLive(sellerId1,list.get(1),productID);
			//组装请求并CALL接口
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, 2);
			Date startTime = c.getTime();
			c.add(Calendar.HOUR, 16);
			Date endTime = c.getTime();
			Map<String, Object> updateMap = new HashMap<String, Object>();
			updateMap.put("ActivityRequest->UserId", sellerId1);
			updateMap.put("ActivityRequest->ActivityId", list.get(1));
			updateMap.put("ActivityRequest->StartTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(startTime));
			updateMap.put("ActivityRequest->EndTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(endTime));
			JSONObject result = modifyActivityCall.callAndGetReturnData(updateMap);
			JSONObject jsonBeanRequest = result.getJSONObject("JsonBeanRequest");			
			//检查listingtime
			SellerProductCallService.checkSqlListingTime(productID, 3);
			SellerProductCallService.checkListingTime(productID, null);

			if (YmtMongoDriverFactroy.isNewJavaMgoCheck()) {
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(list.get(0),productID);
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(list.get(1),productID);
			}
			
		}catch(Exception e){
			Logger.fail(e);
		}
		
		
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ModifyActivity_006() {
		Logger.start(true,"listingtime未过，编辑直播时间，直播A<商品上架时间<修改后的直播时间B，listingtime为直播A开始时间");
		try{
			//创建多个直播
			List<Integer> list = LiveCallService.createLivesInFuture(sellerId1, sellerName1, 2, 1);
			//发布一个5天之后上架的商品
			String productID = SellerProductCallService.addNewProductOnTime(sellerId1, sellerName1, null).getJSONObject("Data").getString("ProductID");
			//商品加入直播
			SellerProductCallService.addProductInLive(sellerId1,list.get(0),productID);
			SellerProductCallService.addProductInLive(sellerId1,list.get(1),productID);
			//组装请求并CALL接口
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, 6);
			Date startTime = c.getTime();
			c.add(Calendar.HOUR, 16);
			Date endTime = c.getTime();
			Map<String, Object> updateMap = new HashMap<String, Object>();
			updateMap.put("ActivityRequest->UserId", sellerId1);
			updateMap.put("ActivityRequest->ActivityId", list.get(1));
			updateMap.put("ActivityRequest->StartTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(startTime));
			updateMap.put("ActivityRequest->EndTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(endTime));
			JSONObject result = modifyActivityCall.callAndGetReturnData(updateMap);
			JSONObject jsonBeanRequest = result.getJSONObject("JsonBeanRequest");			
			//检查listingtime
			SellerProductCallService.checkSqlListingTime(productID, 3);
			SellerProductCallService.checkListingTime(productID, null);
			
			if (YmtMongoDriverFactroy.isNewJavaMgoCheck()) {
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(list.get(0),productID);
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(list.get(1),productID);
			}
			
		}catch(Exception e){
			Logger.fail(e);
		}
		
		
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ModifyActivity_007() {
		Logger.start(true,"listingtime未过，编辑直播时间，商品上架时间<直播A<修改后的直播时间B，listingtime为商品上架时间");
		try{
			//创建多个直播
			List<Integer> list = LiveCallService.createLivesInFuture(sellerId1, sellerName1, 2, 6);
			//发布一个5天之后上架的商品
			String productID = SellerProductCallService.addNewProductOnTime(sellerId1, sellerName1, null).getJSONObject("Data").getString("ProductID");
			//商品加入直播
			SellerProductCallService.addProductInLive(sellerId1,list.get(0),productID);
			SellerProductCallService.addProductInLive(sellerId1,list.get(1),productID);
			//组装请求并CALL接口
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, 8);
			Date startTime = c.getTime();
			c.add(Calendar.HOUR, 16);
			Date endTime = c.getTime();
			Map<String, Object> updateMap = new HashMap<String, Object>();
			updateMap.put("ActivityRequest->UserId", sellerId1);
			updateMap.put("ActivityRequest->ActivityId", list.get(1));
			updateMap.put("ActivityRequest->StartTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(startTime));
			updateMap.put("ActivityRequest->EndTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(endTime));
			JSONObject result = modifyActivityCall.callAndGetReturnData(updateMap);
			JSONObject jsonBeanRequest = result.getJSONObject("JsonBeanRequest");			
			//检查listingtime
			SellerProductCallService.checkSqlListingTime(productID, 2);
			SellerProductCallService.checkListingTime(productID, null);
			
			if (YmtMongoDriverFactroy.isNewJavaMgoCheck()) {
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(list.get(0),productID);
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(list.get(1),productID);
			}
		}catch(Exception e){
			Logger.fail(e);
		}
		
		
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ModifyActivity_008() {
		Logger.start(true,"验证直播内多个商品，编辑直播时，修改多个商品的listingtime");
		try{
			//创建1个未开始的直播
			Integer activityid = LiveCallService.createLiveBeginInFuture(sellerName, sellerId).getJSONObject("Data").getInt("ActivityId");
			//发布2个不上架商品
			String productid1 = SellerProductCallService.addNewProductNotOnSale(sellerId, sellerName, null).getJSONObject("Data").getString("ProductID");
			String productid2 = SellerProductCallService.addNewProductNotOnSale(sellerId, sellerName, null).getJSONObject("Data").getString("ProductID");
			//加入直播
			SellerProductCallService.addProductInLive(sellerId, activityid, productid1);
			SellerProductCallService.addProductInLive(sellerId, activityid, productid2);
			//组装请求并CALL接口
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, 8);
			Date startTime = c.getTime();
			c.add(Calendar.HOUR, 16);
			Date endTime = c.getTime();
			Map<String, Object> updateMap = new HashMap<String, Object>();
			updateMap.put("ActivityRequest->UserId", sellerId1);
			updateMap.put("ActivityRequest->ActivityId", activityid);
			updateMap.put("ActivityRequest->StartTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(startTime));
			updateMap.put("ActivityRequest->EndTime",new SimpleDateFormat(YMTDateUtil.YMDHMS).format(endTime));
			JSONObject result = modifyActivityCall.callAndGetReturnData(updateMap);
			JSONObject jsonBeanRequest = result.getJSONObject("JsonBeanRequest");			
			//检查listingtime
			Date listingTimePre  = new YmtProductsIWapper().selectProductByProductId(productid1).get(0).getdListingTime();
			System.out.println(YmtMongoDriverFactroy.isUpdate("ProductDetailModel", MapUtil.hashMap("ProductId",productid1), MapUtil.hashMap("NewStartTime", listingTimePre)));
			
			
			SellerProductCallService.checkSqlListingTime(productid1, 3);
			SellerProductCallService.checkListingTime(productid1, null);
			
			SellerProductCallService.checkSqlListingTime(productid2, 3);
			SellerProductCallService.checkListingTime(productid2, null);
			
			if (YmtMongoDriverFactroy.isNewJavaMgoCheck()) {
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(activityid,productid1);
				NewJavaMongoCheckService.checkLiveMgoSyncBySQL_NewJavaMgo(activityid,productid2);
			}
			
		}catch(Exception e){
			Logger.fail(e);
		}
		
		
	}
	
	
	
	public void checkModifyActivity(int activityId ,JSONObject jsonBeanRequest ,Date startTime, Date endTime) throws Exception {
	    try {	 
		    //sql断言映射关系
			Map<String,String> sqlMap = sqlMap();			
			//SQL
			List<Map> productsInActivity =  (List<Map>) new YmtLiveWapper().selectforMapByLiveId(activityId);
			HashMap<String, Object> actRetMapbysql = (HashMap<String, Object>) productsInActivity.get(0);
			//SQL断言
			AssertService.assertResultEqual(sqlMap,jsonBeanRequest,actRetMapbysql);
			
			//SQL时间对比
			Map<String,Object> ret = MapUtil.pojoToMap(new YmtLiveWapper().selectByLiveId(activityId));			
			AssertService.assertTime(startTime, (Date)ret.get("dbegintime"), 40);
			AssertService.assertTime(endTime, (Date)ret.get("dendtime"), 40);
			
			
			if (YmtMongoDriverFactroy.isOldMongoCheck()){
				//Mongo老库映射关系
				Map<String,String> oldMongoMap = oldMongoMap();
				//old Mongo
				Map<String, Object>liveBasicInfoMap = new LiveBasicInfoWapper().getActivityId(activityId);
				//断言
				AssertService.assertResultEqual(oldMongoMap,jsonBeanRequest,liveBasicInfoMap);
				
				AssertService.assertTime(startTime, (Date)liveBasicInfoMap.get("StartTime"), 40);
				AssertService.assertTime(endTime, (Date)liveBasicInfoMap.get("EndTime"), 41);
				AssertService.assertTime(YMTDateUtil.getDate(), (Date)liveBasicInfoMap.get("AddTime"), 1000);				
				
			}
			
			
			if (YmtMongoDriverFactroy.isNewMongoCheck()){				
				Map<String,String> newMongoMap = newMongoMap();
				
				LiveModelWapper liveModelWapper =  new LiveModelWapper();
				Logger.verifyEquals(1, liveModelWapper.getCountByActivityId(activityId), "活动数据应该只有1条");
				Map<String, Object> liveModelMap = liveModelWapper.getActivityId(activityId);
								
				AssertService.assertResultEqual(newMongoMap,jsonBeanRequest,liveModelMap);				
								
				AssertService.assertTime(startTime, (Date)liveModelMap.get("StartTime"), 42);
				AssertService.assertTime(endTime, (Date)liveModelMap.get("EndTime"), 43);
				AssertService.assertTime(YMTDateUtil.getDate(), (Date)liveModelMap.get("AddTime"), 1001);
				
			}
	    	
			

	    }catch (Exception e) {  
	        e.printStackTrace();	        
	    }  

	}
	
	
	
}
